﻿using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DAL
{
    public class UserInfoTabDal
    {
        /// <summary>
        /// 注册
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int RegUser(UserInfo model)
        {
            
            string auth = string.Format("select * from UserInfoTab where id='{0}'", model.ID);
            Object obj = SqlHelper.ExecuteScalar(auth);
            if (obj != null)
            {
                return -1;
            }
            string sql = string.Format("insert into UserInfoTab(id,pwd) values('{0}','{1}')", model.ID, model.Password);
            return SqlHelper.ExecuteNonQuery(sql);
        }
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public object Login(UserInfo model)
        {
            
            string sql = string.Format("select * from UserInfoTab where id='{0}' and pwd='{1}'", model.ID, model.Password);
            return SqlHelper.ExecuteScalar(sql);
        }
    }
}
